home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / HyperCard Related / XCMDs & XFCNs / Logic Manager / Stacks / queen.p < prev    next >
Encoding:
Text File  |  1991-03-13  |  732 b   |  37 lines  |  [TEXT/MPS ]

  1. % Logic Manager Copyright 1990 by Apple Computer, Inc.
  2. % Ruben Kleiman (Advanced Technology Group)
  3.  
  4. % The 8 Queens program
  5.  
  6.   ch(1).
  7.   ch(2).
  8.   ch(3).
  9.   ch(4).
  10.   ch(5).
  11.   ch(6).
  12.   ch(7).
  13.   ch(8).
  14.  
  15.  
  16. rule(queen(A,B,C,D,E,F,G,H),
  17.       good(cons(c(1,A),cons(c(2,B),cons(c(3,C),cons(c(4,D),cons(c(5,E),
  18.     cons(c(6,F),cons(c(7,G),cons(c(8,H),nil)))))))))).
  19.  
  20. good(nil).
  21. rule(good(cons(X,Y)),
  22.     and(good(Y),nocollision( X,Y ))).
  23.  
  24. nocollision(X,nil).
  25. rule(nocollision(X,cons(First,Rest)), 
  26.     and(notoppose(X,First), nocollision(X,Rest))).
  27.  
  28. rule(notoppose(c(X1,Y1),c(X2,Y2)),
  29.     and(ch(Y1),
  30.     and(ch(Y2),
  31.     and(different(Y1,Y2),
  32.     and(is(Z1,sub(Y1,Y2)),
  33.     and(is(Z2,sub(X1,X2)),
  34.     and(different(Z1,Z2),
  35.     and(is(Z3,sub(X2,X1)),
  36.     different(Z1,Z3))))))))).
  37.